#include "../source/server.hpp"

int main()
{
    Socket svr_sock;
    bool ret = svr_sock.CreateServerConn(8888);
    int newfd = svr_sock.Accpet();
    if (newfd < 0)
        return 1;

    DLOG("get a new link!");
    Socket cli_sock(newfd);

    while (1)
    {
        char buf[1024] = {0};
        int ret = cli_sock.Recv(buf, 1023);
        if (ret == 0)
        {
            cli_sock.Close();
            break;
        }

        std::string resp = "server echo# " + std::string(buf);
        cli_sock.Send(resp.c_str(), resp.size());
    }
    cli_sock.Close();
    svr_sock.Close();
    return 0;
}